package com.itheima.service;

import com.itheima.dao.TeacherDao;
import com.itheima.domain.Teacher;

import java.util.ArrayList;

public class TeacherService {
    TeacherDao teaDao=new TeacherDao();
    public boolean exists(String id) {
        ArrayList<Teacher> list =teaDao.findAllTeacher();
        for (int i = 0; i < list.size(); i++) {
            if(id.equals(list.get(i).getId())){
                return false;
            }
        }
        return true;
    }

    public void addTeacher(Teacher tea) {
        teaDao.addTeacher(tea);
    }

    public ArrayList<Teacher> searchTeacher() {
                ArrayList<Teacher> list=teaDao.findAllTeacher();
                return list;
    }

    public void updateTeacher(Teacher tec) {
        teaDao.updateTeacher(tec);
    }

    public void deleteTeacher(String id) {
        teaDao.deleteTeacher(id);

    }
}
